export function formatTime(format: string, date: Date): string {
  const year = String(date.getFullYear())
  const month = String(date.getMonth() + 1).padStart(2, '0')
  const day = String(date.getDate()).padStart(2, '0')
  const hours = String(date.getHours()).padStart(2, '0')
  const minutes = String(date.getMinutes()).padStart(2, '0')
  const seconds = String(date.getSeconds()).padStart(2, '0')

  const formatMap: { [key: string]: string } = {
    'YYYY': year,
    'YY': year.toString().slice(-2),
    'MM': month,
    'DD': day,
    'hh': hours,
    'mm': minutes,
    'ss': seconds
  }

  return format.replace(/YYYY|YY|MM|DD|hh|mm|ss/g, (matched) => formatMap[matched])
}